/*
 * FinalChromosome.java
 *
 * Created on November 27, 2007, 7:27 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package simfinal;

import java.util.Random;

/**
 *
 * @author Eric Drucker
 */
public class FinalChromosome implements Comparable<FinalChromosome>
{
	
	private String alleles;
	
	private double fitness = 0;
	
	Random rand = new Random();
	
	/** Creates a new instance of FinalChromosome */
	public FinalChromosome()
	{
		//Random rand = new Random();	//this needs to use JSIM
		
		String newAlleles = "";
		
		for(int i = 0; i < FinalDATA.FIRING_LENGTH; i++)
		{
			if(i < 100)
			{
				newAlleles += "1";
			}
			
			else
			{
				if(rand.nextDouble() < 0.5)
					newAlleles += "0";
				else
					newAlleles += "1";
			}
		}
		
		alleles = newAlleles;
	}
	
	public FinalChromosome(String alleles)
	{
		this.alleles = alleles;
	}

	public String getAlleles()
	{
		return alleles;
	}

	public void setAlleles(String alleles)
	{
		this.alleles = alleles;
	}

	public double getFitness()
	{
		return fitness;
	}

	public void setFitness(double fitness)
	{
		this.fitness = fitness;
	}

	public int compareTo(FinalChromosome o)
	{
		if(this.fitness < o.getFitness())
			return -1;
		else if(this.fitness == o.getFitness())
			return 0;
		else
			return 1;
	}
	
}
